package com.meitianhui.convenitenbuy.module.wallet.presenter;

import com.meitianhui.convenitenbuy.App;
import com.meitianhui.convenitenbuy.base.BaseResponse;
import com.meitianhui.convenitenbuy.config.InfoProvider;
import com.meitianhui.convenitenbuy.http.ResponseObserver;
import com.meitianhui.convenitenbuy.module.wallet.contract.WalletPaymentShowContract;
import com.meitianhui.convenitenbuy.module.wallet.http.WalletApiDataSource;
import com.meitianhui.convenitenbuy.module.wallet.model.CodeFlowBean;
import com.meitianhui.convenitenbuy.module.wallet.ui.activity.WalletPaymentShowActivity;


/**
 * Created by Administrator on 2017/11/2.
 */

public class WalletPaymentShowPresenter implements WalletPaymentShowContract.Presenter {

    private WalletPaymentShowActivity context;
    private final WalletPaymentShowContract.View view;

    public WalletPaymentShowPresenter(WalletPaymentShowActivity view,
                                      WalletPaymentShowActivity context) {
        this.view = view;
        this.context = context;
    }

    @Override
    public void attachView(Object view) {
    }

    @Override
    public void detachView() {
    }

    @Override
    public void getPaymentCode() {
        WalletApiDataSource.getInstance()
                .getPaymentCode(InfoProvider.getAppToken(App.getInstance()))
                .subscribe(new ResponseObserver<BaseResponse<CodeFlowBean>>(App.getInstance()) {
                    @Override
                    public void onSuccess(BaseResponse<CodeFlowBean> response) {
                        view.getPaymentCodeBack(response.data);
                    }
                });
    }

}
